package com.fz.song.web.mapper;

import com.fz.song.web.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author 宋发准
 * @since 2021-11-01
 */
public interface UserMapper extends BaseMapper<User> {

    /**
     * 乐观扣减
     *
     * @param id
     * @param money
     * @param version
     * @return
     */
    int updateUserMoneyBySub(Integer id, int money, int version);

    /**
     * 乐观新增
     *
     * @param id
     * @param money
     * @param version
     * @return
     */
    int updateUserMoneyByAdd(Integer id, int money, int version);


    /**
     * 悲观扣减
     *
     * @param id
     * @param money
     * @return
     */
    int transferPessimismSub(int id, int money);

    /**
     * 悲观新增
     *
     * @param id
     * @param money
     * @return
     */
    int transferPessimismAdd(int id, int money);

    User getByIdForUpdate(int fromId);

}
